<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>内容列表 - Powered By Betou</title>
<meta name="author" content="Betou Team" />
<meta name="copyright" content="Betou" />
<#include "../head_list.html"/>
<script type="text/javascript">
$().ready(function() {
	<#if pagination.totalCount==0>
		$.message("warn", "暂无数据！");
	</#if>
	
	var $listForm = $("#listForm");
	var $selectAll = $("#selectAll");
	var $createPageButton = $("#createPageButton");
	var $checkboxIds = $("#listTable input[name='ids']");
	var createPageUri = "o_createdPage.jspx"; 
	
	var createPage = function(data){
		$.ajax({
			url: createPageUri ,
			type: "POST",
			data: data,
			cache: false,
			success: function(message) {
				if( typeof(message) == 'string' ){
					var msg = "系统繁忙，请稍后重试！"
					message = {type:"error", content: msg };
				}
				$.message(message);
				if (message.type == "success") {
					setTimeout(function() {
						$listForm.submit();
					}, 2000);
				}
			},
			error:function(xmlHttpRequest, message, e){
				$.message( "error", e );
			}
		});
	}
	
	$("[name=createdPageButton]").click( function() {
		var $this = $(this);
		var id = $this.attr("val");
		createPage({ids: id});
	})
	
	$("#createPageButton").click( function() {
		var $this = $(this);
		if ($this.hasClass("disabled")) {
			return false;
		}
		var $checkedIds = $checkboxIds.filter(":checked");
		createPage($checkedIds.serialize());
	});
	
	var clickSelected = function (){
		var $this = $(this);
		if ($checkboxIds.filter(":checked").size() > 0) {
			$createPageButton.removeClass("disabled");
		} else {
			$createPageButton.addClass("disabled");
		}
	}
	
	$checkboxIds.click(clickSelected);	
	$selectAll.click(clickSelected);
});

</script>
</head>
<body class="content">
	<div class="path">
		<a href="../index.jspx">首页</a> &raquo; 内容列表 <span>(共<span id="pageTotal">${pagination.totalCount!0}</span>条记录)</span>
	</div>
	<form id="listForm"  class="clearfix" action="v_list.jspx?view=content" method="post">
		<input type="hidden" name="cid"  value="${cid!}" />
 		<div class="bar">
			<div class="buttonWrap">
				<#include "../pageselect.html"/>
			</div>
			<div class="menuWrap">
				<div class="search">
					<span id="searchPropertySelect" class="arrow">&nbsp;</span>
					<input type="text"  id="searchValue" name="searchValue" value="${searchValue!}" maxlength="200" />
					<button type="submit">&nbsp;</button>
				</div>
				<div class="popupMenu">
					<ul id="searchPropertyOption">
						<li><a href="javascript:;" val="title">标题</a></li>
						<li><a href="javascript:;" val="admin.username">发布人</a></li>
					</ul>
				</div>
			</div>
		</div>
		<table id="listTable" class="list">
			<tr>
				<th class="check"><input type="checkbox" id="selectAll" /></th>
				<th><a href="javascript:;" class="sort" name="title">标题</a></th>
				<th><span>栏目</span></th>
				<th><a href="javascript:;" class="sort" name="pubDate">发布日期</a></th>
				<th><a href="javascript:;" class="sort" name="recommend">推荐</a></th>
				<th><a href="javascript:;" class="sort" name="created" title="是否已生成静态页面">静态页面</a></th>
				<th><a href="javascript:;" class="sort" name="admin.username">发布人</a></th>
				<th><span>操作</span></th>
			</tr>
			<#list pagination.list as c>
				<tr>
					<td><input type="checkbox" name="ids"  title=""  value="${c.id!}" /></td>
					<td>
						<a href="/content/view.jhtml?id=${c.id!}" target="_blank" title="预览">${c.title!}</a>
					</td>	
					<td><span class="green">${c.channel.name}</span></td>
					<td>
						<span title="${c.pubDate?string('yyyy-MM-dd hh:mm:ss')}">${c.pubDate?string('yyyy-MM-dd')}</span>
					</td>
					<td>
						<#if c.recommend>
							<span class="trueIcon">&nbsp;</span>
						<#else>
							<span class="falseIcon">&nbsp;</span>
						</#if>
					</td>
					<td>
						<#if c.created>
							<span class="trueIcon">&nbsp;</span>
						<#else>
							<span class="falseIcon">&nbsp;</span>
						</#if>
					</td>
					<td>${c.admin.username!}</td>
					<td>
						<a href="../content/v_edit.jspx?id=${c.id!}">[查看]</a>&nbsp;&nbsp;
					</td>
				</tr>
			</#list>
		</table>
		<#include "../list_hidden.html" />
		<#include "../page.html" />
	</form>
</body>
</html>